<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            width: 100%;
            height: 100%;
        }
        #app{
            padding: 0 20px;
        }
        .top{
            text-align: center;
            margin-bottom: 20px;
        }
        .top input{
            height: 30px;
        }
        .center{
            height: 30px;
            width: 50px;
            display: flex;
            justify-content: space-around;
            background-color: #ccc;
            margin-bottom: 20px;
            line-height: 30px;
            border-radius: 20px;
            margin-left: 20px;
        
        }
        .active{
            background-color: lightgreen;
        }
        .bod1{
            display: flex;
        }
        .head{
            height: 50px;
            line-height: 50px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="head"><搜索</div>
        <div class="top">
            <input type="text" v-model="inputText">
        <input type="button" value="搜索" @click="add()">
        </div>
        <div class="bod1">
            <div :class="`center ${item.status? 'active':''}`" v-for="(item,index) in datalist" :key="index">
                <p>{{item.name}}</p>
        </div>
        </div>
       
        <!-- <div class="empty" v-if="datalist.length==0">任务列表空空如也</div> -->
    </div>
</body>
</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var v=new Vue({
        el:'#app',
        data:{
            inputText:'',
            datalist:[
                // {id:1,name:'任务名称',status:true}
            ]
        },
        methods:{
            add(){
                var obj={id:this.datalist.length+1,name:this.inputText,status:false}
                //输入框不为空时，才去添加数据
               if(this.inputText){
                this.datalist.push(obj)
                console.log(this.datalist);
                this.inputText=''
               }
                
            },
            changeStatus(item){
                item.status=!item.status
            }
        }
    })
</script>